package quotation.utils;



public class LoginInfoUtil {


    private LoginInfoUtil() {
    }

    private static volatile LoginInfoUtil loginInfoUtil = null;

    private final static ThreadLocal<LoginInfo> requestHolder = new ThreadLocal<>();

    public static LoginInfoUtil getInstance() {

        if (loginInfoUtil == null) {
            synchronized (LoginInfoUtil.class) {
                if (loginInfoUtil == null) {
                    loginInfoUtil = new LoginInfoUtil();
                }
            }
        }
        return loginInfoUtil;

    }

    public void add(LoginInfo model) {
        requestHolder.set(model);
    }

    private LoginInfo get() {
        return requestHolder.get();
    }

    public Long getUserId() {
        return this.get() == null ? 0 : this.get().userId;
    }

    public Integer getType() {
        return this.get() == null ? 0 : this.get().type;
    }

    public String getName() {
        return this.get() == null ? "" : this.get().userName;
    }


    public void remove() {
        requestHolder.remove();
    }


}
